package com.scommunity.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.scommunity.admin.vo.HelpVO;
import com.scommunity.conf.CacheConf;
import com.scommunity.domain.Help;
import com.scommunity.domain.HelpItem;
import com.scommunity.mapper.HelpItemMapper;
import com.scommunity.mapper.HelpMapper;
import com.scommunity.service.IHelpItemService;
import com.scommunity.service.IHelpService;
import com.scommunity.utils.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class HelpServiceImpl extends ServiceImpl<HelpMapper, Help> implements IHelpService {


    @Autowired
    private HelpMapper helpMapper;
    @Autowired
    private IHelpItemService helpItemService;


    @Cacheable(value = "helpItemList")
    @Override
    public List<HelpItem> getList() {
//        System.out.println(helpItemService.getList());
        List<HelpItem> helpItemList = helpItemService.getList();
//        List<Help> helpList = helpMapper.selectList(null);
//        List<HelpVO> helpVOList = new ArrayList<>();
//        for (Help help : helpList) {
//            HelpVO helpVO = new HelpVO();
//            helpVO.setHelp(help);
//            List<HelpItem> helpItemList = helpItemService.list(new QueryWrapper<HelpItem>().eq("help_id", help.getHelpId()));
//            helpVO.setHelpItemList(helpItemList);
//            helpVOList.add(helpVO);
//        }
        return helpItemList;
    }
}
